/*
 * @Descripttion: 
 * @Author: liuYaoYu
 * @Date: 2021-12-20 09:51:32
 * @LastEditors: liuYaoYu
 * @LastEditTime: 2021-12-20 10:12:56
 */


 package main
//  双向排序
import (
	"fmt"
)
func binaryFind(arr *[5]int,firstIndex int,lastIndex,findVal int){
	middle :=(firstIndex+lastIndex)/2
	if (*arr)[middle]<findVal{
		binaryFind(arr,firstIndex,middle-1,findVal)
	}else if(*arr)[middle]>findVal{
		binaryFind(arr,middle+1,lastIndex,findVal)
	}else{
		fmt.Printf("找到了 下表为%v\n",middle)
	}
	
}

func main (){
	var arr [5]int=[...]int{4,5,6,7,8}
	binaryFind(&arr,0,len(arr),8)
}